#include <iostream>
#include <fstream>
#include <vector>
#include <unordered_set>
#include "bruteforce.hpp"
#include "vecs_io.hpp"

using namespace std;
using namespace MultipleHNSW;

int main() {
    const char *dataset_name = "gistsmall";
    int n_query, top_k, n_base, data_dim;
    top_k = 10;

    vector<float *> data = read_data(dataset_name, n_query, top_k, n_base, data_dim);
    float *base = data[0];
    float *query = data[1];
    int *gnd = (int *) data[2];

    BruteForceSearch bfs(data_dim, n_base);
    bfs.insert(base);

    printf("querying\n");
    vector<unordered_set<int>> test_gnd_l = bfs.search_knn(query, top_k, n_query);
    bool equal = true;
    for (int i = 0; i < n_query; i++) {
        for (int j = 0; j < top_k; j++) {
            int tmp = gnd[i * top_k + j];
            if (test_gnd_l[i].find(tmp) == test_gnd_l[i].end()) {
                equal = false;
            }
        }
    }

    if (equal) {
        printf("equal to the ground truth\n");
    } else {
        printf("not equal to the ground truth\n");
    }

    return 0;
}